<template>
  <div>
    <!--表格内容-->
    <el-table
      ref=""
      :data="tableData"
      style="width: 100%; margin-bottom: 5px"
      border
      stripe
      highlight-current-row
      :default-sort="{ prop: 'date', order: 'descending' }"
      @row-click="handleRowClick"
      @select-all="handleCheckedAllAndCheckedNone"
      @select="handleCheckedAllAndCheckedNone"
    >
      <el-table-column fixed type="selection" align="center">
      </el-table-column>
      <el-table-column property="auctionId" label="拍卖会编号" width="100">
      </el-table-column>
      <el-table-column property="auctionName" label="拍卖会名称" width="150">
      </el-table-column>
      <el-table-column property="name" label="竞买人" >
      </el-table-column>
      <el-table-column property="id" label="竞买号" width="100">
      </el-table-column>
      <el-table-column property="phone" label="绑定手机号" width="130">
      </el-table-column>
      <el-table-column property="cardId" label="证件号" width="150">
      </el-table-column>
      <el-table-column property="enrollTime" label="报名时间" width="180">
      </el-table-column>
      <el-table-column property="enrollType" label="报名方式" >
      </el-table-column>
      <el-table-column property="authorized" label="是否授权" >
      </el-table-column>
      <el-table-column property="authorizedNum" label="授权标的数" width="100">
      </el-table-column>
      <el-table-column property="tradableNum" label="可交易数量" width="100">
      </el-table-column>
      <el-table-column property="withhold" label="保证金暂扣" width="100">
      </el-table-column>
      <el-table-column property="remark" label="备注" >
      </el-table-column>

      <el-table-column fixed="right" label="操作" width="240" align="center">
        <template slot-scope="scope">
          <el-button circle icon="el-icon-view" title="详情" type="success" size="small" @click="upload()"></el-button>
          <el-button
            circle
            icon="el-icon-s-claim"
            type="primary"
            title="确认缴纳"
            size="small"
            @click="confirm(scope.$index, scope.row)"
          ></el-button>
          <el-button
            circle
            icon="el-icon-delete"
            type="danger"
            title="删除"
            size="small"
            @click="rowDel(scope.$index, scope.row, $event)"
          ></el-button>
        </template>
      </el-table-column>


    </el-table>
    <!--分页-->
    <!-- <el-pagination
      :page-sizes="[10, 20, 30, 40, 100]"
      :page-size="10"
      :total="100"
      layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination> -->
    <Confirm v-if="isShowConfirmDialog" :isShowConfirmDialog="isShowConfirmDialog"
      @dialogClose="dialogClose"
      @submitData="submitData"></Confirm>
    <Add v-if="isShowAddDialog" :isShowAddDialog="isShowAddDialog"  @dialogClose="dialogClose" @submitData="submitData"></Add>
  </div>
</template>
    
  <script>
  import Confirm from "./confirm";
  import Add from "./bidderAdd";
  export default {
  name: "BidderManage",
  components: {
    Confirm,
    Add,
  },
  data() {
    return {
      formFileds: {},

      tableData: [
        {
          auctionId: '网络123',
          auctionName: '沈阳汽车拍卖专场1',
          name: '小红花',
          id: '456789123',
          phone: '13388885555',
          cardId: '789123456',
          enrollTime: '2022-09-29 14:00:00',
          enrollType: '单标的',
          authorized: '已授权',
          authorizedNum: '1',
          tradableNum: '1',
          withhold: '暂扣',
          remark: '',

        }
      ],
      isShowConfirmDialog: false,
      isShowAddDialog: false,
      
    };
  },
  methods: {
    handleRowClick(row, event, column) {
      // 仅选中当前行
      this.setCurRowChecked(row);
    },
    handleCheckedAllAndCheckedNone(selection) {
      // 当前选中仅一行时操作-（当前表格行高亮）
      1 != selection.length && this.$refs.list.setCurrentRow();
    },
    dialogClose() {
      this.isShowConfirmDialog = false;
      this.isShowAddDialog = false;
    },
    submitData(){
      console.log('提交');
    },
    add(){
      this.isShowAddDialog = true;
    },
    confirm(index, row) {
      // //当前选中行
      this.formFileds = row;
      this.isShowConfirmDialog = true;
    },
    handleEdit(id) {
      this.$refs.editForm.validate((isValid) => {
        if (!isValid) return;

        // 保存编辑后的数据
        Object.assign(this.tableData[id], this.formFileds);
        this.isShowEditDialog = false;

        // 考虑到可能编辑了日期-需要重新排序
        // ***注意：手动排序传参和表格的default-sort属性格式不太一样
        this.$refs.list.sort("date", "descending");

        this.$message.success("编辑成功");
      });
    },
    rowDel(index, row, event) {
      // 让当前删除按钮失焦
      event.target.blur();

      this.$confirm("确定要删除当前行吗？", "删除", {
        comfirmButtonText: "确定",
        cancelButtonText: "取消",
      }).then(() => {
        this.tableData.splice(row.id, 1);
        this.$message.success("删除成功");
        return false;
      });
    },
    deleteAll() {
      this.$confirm("确定要删除这些行吗？", "删除", {
        comfirmButtonText: "确定",
        cancelButtonText: "取消",
      }).then(() => {
        this.$message.success("删除成功");
        return false;
      });
    },
    // 选中当前行-当前行的复选框被勾选
    setCurRowChecked(row) {
      this.$refs.list.clearSelection();
      this.$refs.list.toggleRowSelection(row);
    },
  },
};
</script>
    
<style scoped lang="less">
.el-form {
  padding: 0 10px;
}

.el-date-editor {
  width: 100% !important;
}
</style>
    